package com.yyf.springboot2.controller;

import com.alibaba.fastjson.JSONObject;
import com.yyf.springboot2.common.ResultBean;
import com.yyf.springboot2.entity.TImage;
import com.yyf.springboot2.service.TImageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yyf
 * @since 2019-05-29
 */
@Controller
@RequestMapping("/tImage")
public class TImageController {
    @Resource
    private TImageService imageService;

    @GetMapping("/banner/list")
    public ResultBean bannerList(@PathVariable(value = "type",required = false) String type){
        System.out.println("type"+type);
        List<TImage> newBannerList = null;
        //轮播图
        if(type == null){
            type = "new";
        }
        if(type.equals("new")){
            newBannerList  =  imageService.getNewBannerList(type);
        }
        JSONObject jsonObject = JSONObject.parseObject(newBannerList.toString());
        System.out.println("/banner/list");
        return ResultBean.build(200,"",jsonObject);
    }
	
}
